"""统一状态码定义"""
from enum import Enum
from typing import Tuple


class StatusCode(Enum):
    """业务状态码枚举"""
    
    # 成功状态码 (10000-19999)
    SUCCESS = (10000, "操作成功")
    
    # 客户端错误状态码 (20000-29999)
    INVALID_PARAMS = (20000, "参数错误")
    MISSING_PARAMS = (20001, "缺少必要参数")
    INVALID_TOKEN = (20002, "无效的令牌")
    TOKEN_EXPIRED = (20003, "令牌已过期")
    UNAUTHORIZED = (20004, "未授权访问")
    FORBIDDEN = (20005, "禁止访问")
    RESOURCE_NOT_FOUND = (20006, "资源不存在")
    USER_NOT_FOUND = (20007, "用户不存在")
    USER_ALREADY_EXISTS = (20008, "用户已存在")
    INVALID_CREDENTIALS = (20009, "用户名或密码错误")
    
    # 服务器错误状态码 (30000-39999)
    INTERNAL_ERROR = (30000, "服务器内部错误")
    DATABASE_ERROR = (30001, "数据库错误")
    EXTERNAL_SERVICE_ERROR = (30002, "外部服务错误")
    
    def __init__(self, code: int, message: str):
        self.code = code
        self.message = message
    
    @property
    def value(self) -> Tuple[int, str]:
        return (self.code, self.message)


class HttpStatusCode:
    """HTTP状态码常量"""
    
    # 成功响应
    OK = 200
    CREATED = 201
    NO_CONTENT = 204
    
    # 客户端错误
    BAD_REQUEST = 400
    UNAUTHORIZED = 401
    FORBIDDEN = 403
    NOT_FOUND = 404
    METHOD_NOT_ALLOWED = 405
    CONFLICT = 409
    UNPROCESSABLE_ENTITY = 422
    
    # 服务器错误
    INTERNAL_SERVER_ERROR = 500
    BAD_GATEWAY = 502
    SERVICE_UNAVAILABLE = 503 